package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.domain.Student;
import com.itheima.service.StudentService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/student")
public class StudentController {
    @Reference
    StudentService studentService;
    @RequestMapping("/findAll")
    @ResponseBody
    public List<Student> findAll(){
//        System.out.println(studentService.findAll());
        return studentService.findAll();
    }
    @RequestMapping("/update")
    public String update(Integer id,String name){
        studentService.update(id,name);
        System.out.println(name);
        return "redirect:/student/findAll";
    }
}
